package com.cskaoyan.market.service.impl;

import com.cskaoyan.market.db.domain.MarketFootprint;
import com.cskaoyan.market.db.domain.MarketFootprintExample;
import com.cskaoyan.market.db.mapper.MarketFootprintMapper;
import com.cskaoyan.market.service.AdminFootprintService;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class AdminFootprintServiceImpl implements AdminFootprintService {

    @Autowired
    MarketFootprintMapper mapper;


    @Override
    @Transactional
    public List<MarketFootprint> list(Integer page, Integer limit, Integer userId, Integer goodsId, String sort, String order) {
        MarketFootprintExample marketFootprintExample = new MarketFootprintExample();
        MarketFootprintExample.Criteria criteria = marketFootprintExample.createCriteria();
        if(userId!=null)
            criteria.andUserIdEqualTo(userId);
        if(goodsId!=null)
            criteria.andUserIdEqualTo(goodsId);
        marketFootprintExample.setOrderByClause(sort + " " + order);
        PageHelper.startPage(page,limit);
        List<MarketFootprint> marketFootprints = mapper.selectByExample(marketFootprintExample);
        return marketFootprints;
    }
}
